#pragma once
#include"RBTree.h"
#include<iostream>
#include<windows.h>

using namespace std;
//template <class Key>
//
//class set {
//public:
//    typedef Key key_type;
//    typedef Key value_type;
//
//private:
//    typedef rb_tree<key_type, value_type> rep_type;
//    rep_type t;  // red-black tree representing set
//};

namespace shh
{
    template<class K>
    class MySet
    {
        struct SetKeyOfT
        {
            const K& operator()(const K& key)
            {
                return key;
            }
        };
    public:
        typedef typename RBTree<K, const K, SetKeyOfT>::Iterator iterator;
        typedef typename RBTree<K, const K, SetKeyOfT>::ConstIterator const_iterator;

        bool insert(const K& key)
        {
            return _t.Insert(key);
        }
        iterator begin()
        {
            return _t.Begin();
        }
        iterator end()
        {
            return _t.End();
        }
        void inorder()
        {
            _t.Inorder();
        }
    private:
        RBTree<K, const K, SetKeyOfT> _t;
    };
    void TestMySet()
    {
        MySet<int> s;
        s.insert(4);
        s.insert(2);
        s.insert(5);
        s.insert(15);
        s.insert(7);
        s.insert(1);
        MySet<int>::iterator it = s.begin();
        //s.inorder();
        while (it != s.end())
        {
            cout << *it << endl;
            ++it;
        }

    }
}